import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
export default async function a021(fd: IFeidaoAiBrowserComponent, equip_no: string) {
	// todo
	const ssr = fd.data.node.querySelector<HTMLDivElement>('[data-zzs="ssr"]');
	set_node_cls(ssr, 'display-n', true);
	const sr = fd.data.node.querySelector<HTMLDivElement>('[data-zzs="nr"]');
	set_node_cls(sr, 'display-n', false);

	const res = await nodejs('device-management/zj-000001/s020', {
		filter: {
			equip_no
		}
	});
	const s = res[0] as { _id: string, productid: string, equip_type_name: string, equip_type_no: string, equip_internal_no: string, equip_no: string, equip_name: string, equip_description: string, equipment_state: number, fixed_assets_type: string, fixed_assets_no: string, Former_equip_no: string, transfer_time: string, transfer_price: number, transfer_date: Date, manufacturer: string, manu_country: string, manu_element_no: string, manu_years: string, equip_model: string, series_no: string, geom: string };
	fd.data.node.querySelector<HTMLOptionElement>('[data-zzs="s1"]').value = res[0].equip_type_name;
	fd.data.node.querySelector<HTMLSelectElement>('[data-zzs="equipment_kind_name"]').value = res[0].equip_name;
	fd.data.node.querySelector<HTMLInputElement>('[data-zzs="equip_internal_no1"]').value = res[0].equip_internal_no;
	fd.data.node.querySelector<HTMLSelectElement>('[data-zzs="fixed_assets_type"]').value = res[0].fixed_assets_type;
	fd.data.node.querySelector<HTMLInputElement>('[data-zzs="transfer_price1"]').value = res[0].transfer_price;

	const da = res[0].transfer_time;

	// const y = 1900 + da.getYear();
	// const m = "0" + (da.getMonth() + 1);
	// const d = "0" + da.getDate();
	// const sj1 = y + "-" + m.substring(m.length - 2, m.length) + "-" + d.substring(d.length - 2, d.length);
	// da = new Date(da);
	// // const c = formatDate(da, 'yyyy-MM-dd');
	// const year = da.getFullYear();
	// const month = da.getMonth();
	// const date = da.getDate();
	// const sj1 = ([year, month, date].join('-'));

	// fd.data.node.querySelector<HTMLInputElement>('[data-zzs="transfer_time1"]').setAttribute("value", sj1);



	fd.data.node.querySelector<HTMLInputElement>('[data-zzs="manufacturer1"]').value = res[0].manufacturer;
	fd.data.node.querySelector<HTMLInputElement>('[data-zzs="manu_country1"]').value = res[0].manu_country;
	fd.data.node.querySelector<HTMLInputElement>('[data-zzs="equip_model1"]').value = res[0].equip_model;
	fd.data.node.querySelector<HTMLInputElement>('[data-zzs="manu_element_no1"]').value = res[0].manu_element_no;
	fd.data.node.querySelector<HTMLInputElement>('[data-zzs="series_no1"]').value = res[0].series_no;
	fd.data.node.querySelector<HTMLInputElement>('[data-zzs="transfer_price2"]').value = res[0].transfer_price;
	fd.data.node.querySelector<HTMLInputElement>('[data-zzs="Former_equip_no1"]').value = res[0].former_equip_no;

	// let da2 = res[0].transfer_date;
	// da2 = new Date(da2);
	// const year2 = da2.getFullYear();
	// const month2 = da2.getMonth();
	// const date2 = da2.getDate();
	// const sj3 = ([year2, month2, date2].join('-'));


	// fd.data.node.querySelector<HTMLInputElement>('[data-zzs="transfer_date1"]').value = sj3;
	//////
	fd.data.node.querySelector<HTMLSpanElement>('[data-zzs="geom1"]').value = res[0].geom;
	fd.data.node.querySelector<HTMLSelectElement>('[data-zzs="optional_value"]').value = res[0].optional_value;



	// let da1 = res[0].manu_years;
	// da1 = new Date(da1);
	// const year1 = da1.getFullYear();
	// const month1 = da1.getMonth();
	// const date1 = da1.getDate();
	// const sj2 = ([year1, month1, date1].join('-'));

	// fd.data.node.querySelector<HTMLInputElement>('[data-zzs="manu_years1"]').value = sj2;
	fd.data.node.querySelector<HTMLInputElement>('[data-zzs="equip_description1"]').value = res[0].equip_description;
}
